#include "widget.h"
#include "ui_widget.h"
#include <QPainter>
#include <QBrush>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::paintEvent(QPaintEvent *event)
{
    (void) event;

    QPainter painter(this);

    //设置画笔
    QPen pen;
    pen.setColor(QColor(255,0,0));
    pen.setStyle(Qt::DotLine);
    pen.setWidth(5);
    painter.setPen(pen);

    //设置画刷
    QBrush brush;
    brush.setColor(Qt::blue);
    brush.setStyle(Qt::CrossPattern);
    painter.setBrush(brush);

    //绘制圆形
    painter.drawEllipse(100,100,300,300);
}

